package pers.xuyong.strive.datastruct.mode;

import pers.xuyong.strive.datastruct.mode.single.HungryModeSingleton;
import pers.xuyong.strive.datastruct.mode.single.LazyModeSingleton;
import pers.xuyong.strive.datastruct.mode.single.Singleton;
import pers.xuyong.strive.datastruct.mode.single.SingletonEnum;

/**
 * 设计模式测试
 *
 * @author billymac
 * @version 1.0
 * @date 17/6/23  下午11:29
 * @since JDK1.8
 */
public class Main {

    public static void main(String[] args) {
        /**
         * 饿汉式
         */
        HungryModeSingleton hungryModeSingleton = HungryModeSingleton.getHungryModeSingleton();
        hungryModeSingleton.display();

        /**
         * 懒汉式
         */
        LazyModeSingleton lazyModeSingleton = LazyModeSingleton.getLazyModeSingleton();
        lazyModeSingleton.display();

        /**
         * 静态内部类
         */
        Singleton singleton = Singleton.getInstance();
        singleton.display();

        /**
         * 枚举单例
         */
        SingletonEnum.SINGLETON_ENUM.display();
    }
}
